package com.yuan.zs.ui.account;

import android.os.Bundle;
import android.widget.ListView;

import com.alibaba.fastjson.JSONArray;
import com.yuan.base.framework.BaseFrameworkActivity;
import com.yuan.base.framework.http.BaseHttpCallBack;
import com.yuan.base.framework.http.BaseHttpRequest;
import com.yuan.base.utils.LogUtil;
import com.yuan.base.widget.AutoLoadList;
import com.yuan.zs.R;
import com.yuan.zs.Urls;

import java.util.HashMap;

/**
 * 审批绑定
 */
public class ApplyApprovalActivity extends BaseFrameworkActivity {

	// --------------------------控件--------------------------
	private AutoLoadList auto_load_list;
	private ListView data_list;// 下拉刷新
	// --------------------------变量--------------------------

	@Override
	protected int getLayoutId() {
		return R.layout.activity_apply_approval;
	}

	@Override
	protected void bindViews() {
		auto_load_list = findViewById(R.id.auto_load_list);
		data_list = auto_load_list.getData_list();
		auto_load_list.setOnRefreshingListener(new AutoLoadList.OnRefreshingListener() {
			@Override
			public void onRefresh() {
				getListData();
			}

			@Override
			public void onLoadMore() {
			}
		});
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		auto_load_list.startRefreshing();
	}

	private void getListData() {
		HashMap<String, Object> params = new HashMap<>();
		BaseHttpRequest.get(Urls.getUrl(Urls.applyChildList), params, new BaseHttpCallBack<JSONArray>() {

			@Override
			public void onSuccess(JSONArray result) {
				LogUtil.d(result);
//				if (result != null && result.containsKey("content")) {
//
//				}
			}

			@Override
			public void onPost() {
				auto_load_list.completeRefresh();
			}
		});
	}

//	private void init(boolean needNew) {
//		if (needNew) {
//			noticeAdapter = new NoticeActivity.NoticeAdapter(this);
//			noticeAdapter.setData(dataList);
//			data_list.setAdapter(noticeAdapter);
//		} else {
//			noticeAdapter.setData(dataList);
//			noticeAdapter.notifyDataSetChanged();
//		}
//	}
//
//	private class NoticeAdapter extends BaseViewHolderAdapter<Notice, NoticeActivity.Holder> {
//
//		private NoticeAdapter(Context context) {
//			super(context);
//		}
//
//		@Override
//		protected void bindViews(View convertView, NoticeActivity.Holder holder, Notice item) {
//			holder.tv_notice_title = convertView.findViewById(R.id.tv_notice_title);
//			holder.tv_notice_publisher = convertView.findViewById(R.id.tv_notice_publisher);
//			holder.tv_notice_publish_time = convertView.findViewById(R.id.tv_notice_publish_time);
//			holder.iv_notice_first_img = convertView.findViewById(R.id.iv_notice_first_img);
//		}
//
//		@Override
//		protected View getConvertView(Notice item, LayoutInflater inflater, int position, ViewGroup parent) {
//			return inflater.inflate(R.layout.item_notice_list, parent, false);
//		}
//
//		@Override
//		protected NoticeActivity.Holder getHolder() {
//			return new NoticeActivity.Holder();
//		}
//
//		@Override
//		protected void refreshView(int position, Notice item, View convertView, NoticeActivity.Holder holder) {
//			holder.tv_notice_title.setText(item.getTitle());
//			holder.tv_notice_publisher.setText(item.getPublisher());
//			holder.tv_notice_publish_time.setText(DateUtil.dateToString(item.getPublishDate()).substring(5, 16));
//			if (item.getPicsList() != null && item.getPicsList().length > 0) {
//				BaseImageLoad.load(item.getPicsList()[0], holder.iv_notice_first_img);
//			} else {
//				holder.iv_notice_first_img.setImageResource(R.drawable.base_ic_loading);
//			}
//		}
//	}
//
//	private class Holder {
//		TextView tv_notice_title;
//		TextView tv_notice_publisher;
//		TextView tv_notice_publish_time;
//		ImageView iv_notice_first_img;
//	}

}
